package org.example.jiaxiao.controller;

import org.example.jiaxiao.entity.Account;
import org.example.jiaxiao.service.ViewProfileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/viewProfile")
@CrossOrigin // 解决跨域问题
public class ViewProfileController {
    @Autowired
    private ViewProfileService viewProfileService;

    @RequestMapping("/personalCenter")
    public ResponseEntity<Account> getPersonalCenter
            (@RequestParam(name="accountNumber") Long accountNumber) {
        System.out.println("accountNumber: " + accountNumber);
        Account account = viewProfileService.getPersonalCente(accountNumber);
        System.out.println("account: " + account);
        return ResponseEntity.ok(account);
    }
}
